package jdbc.preparedstatement_;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class homework {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/hsp_db02";
        String user = "root";
        String password = "123456";
        Connection connection = DriverManager.getConnection(url, user, password);

        String sql = "insert into admin values (?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1,"jack");
        preparedStatement.setString(2,"123456");
        int i = preparedStatement.executeUpdate();
        if( i > 0 ){
            System.out.println("登陆成功");
        }

        preparedStatement.close();
        connection.close();
    }
}
